package xyz.xtt.exchange.service;

import java.util.function.Predicate;

import xyz.xtt.exchange.constants.CheckLimitTypeEnum;
import xyz.xtt.exchange.constants.DimensionalTypeEnum;
import xyz.xtt.exchange.vo.AuditCheckResult;

/**
 * @author huqibo
 * @date 2024/11/21
 */
public interface CheckLimitService {

	/**
	 * @param uid                    用户id
	 * @param limitType              检查类型
	 * @param dayTotalRequestCheck   日请求总数检查
	 * @param daySuccessCheck        日成功铸造总数检查
	 * @param dayContinuousFailCheck 日连续失败数检查
	 * @param dayTotalFailCheck      日总失败数检查
	 */
	void checkLimit(String uid, CheckLimitTypeEnum limitType, Predicate<Long> dayTotalRequestCheck, Predicate<Long> daySuccessCheck,
			Predicate<Long> dayContinuousFailCheck, Predicate<Long> dayTotalFailCheck);

	/**
	 * 增加某个计数器的值
	 * 
	 * @param uid
	 * @param limitType
	 * @param dimensionalType
	 */
	void plusDayValue(String uid, CheckLimitTypeEnum limitType, DimensionalTypeEnum dimensionalType);

	/**
	 * 内容审核
	 * 
	 * @param uid
	 * @param limitType
	 * @param context
	 * @param target
	 */
	AuditCheckResult auditCheck(String uid, CheckLimitTypeEnum limitType, String context, String target);

	/**
	 * 域名检验
	 * 
	 * @param url
	 * @return
	 */
	boolean checkDomain(String url);

	/**
	 * 当天已成功功总数
	 * 
	 * @param uid
	 * @param limitType
	 * @return
	 */
	long successTotal(String uid, CheckLimitTypeEnum limitType);
}
